package sfmc.biz.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import sfmc.biz.dao.SfmcCountStatusDao;
import sfmc.biz.service.SfmcCountStatusService;
import sfmc.biz.vo.Sfmc_TB_STATUS;

@Service("SfmcCountStatusService")
public class SfmcCountStatusServiceImpl implements SfmcCountStatusService{

	protected Log log = LogFactory.getLog(this.getClass());
	
	@Autowired
	@Resource(name="SfmcCountStatusDao")
	private SfmcCountStatusDao sfmcCountStatusDao;
	public void setSfmcCountStatusDao(SfmcCountStatusDao sfmcCountStatusDao) {
		this.sfmcCountStatusDao = sfmcCountStatusDao;
	}
	
	@Override
	public List<Sfmc_TB_STATUS> getDailyStatusList(Sfmc_TB_STATUS sfmc_TB_STATUS) {
		
		String where = "";
		
		try{
			if(!"".equals(sfmc_TB_STATUS.getSearchCustName())){
				where += "AND B.CustName LIKE '%"+sfmc_TB_STATUS.getSearchCustName()+"%'\n";
			}
			if(!"".equals(sfmc_TB_STATUS.getSearchCustPhone())){
				where += "AND B.CustPhone LIKE '%"+sfmc_TB_STATUS.getSearchCustPhone()+"%'\n";
			}

			sfmc_TB_STATUS.setWhere(where);
			return sfmcCountStatusDao.getDaillyStatusList(sfmc_TB_STATUS);
		}
		catch(Exception e){
			log.error(e);
			return null;
		}
	}
	
	@Override
	public List<Sfmc_TB_STATUS> getWeeklyStatusList(Sfmc_TB_STATUS sfmc_TB_STATUS) {
		
		String where = "";
			
		try{
			if(!"".equals(sfmc_TB_STATUS.getSearchCustName())){
				where += "AND B.CustName LIKE '%"+sfmc_TB_STATUS.getSearchCustName()+"%'\n";
			}
			if(!"".equals(sfmc_TB_STATUS.getSearchCustPhone())){
				where += "AND B.CustPhone LIKE '%"+sfmc_TB_STATUS.getSearchCustPhone()+"%'\n";
			}
			sfmc_TB_STATUS.setWhere(where);
			return sfmcCountStatusDao.getWeeklyStatusList(sfmc_TB_STATUS);
		}
		catch(Exception e){
			log.error(e);
			return null;
		}
	}
	
	
	@Override
	public List<Sfmc_TB_STATUS> getMonthlyStatusList(Sfmc_TB_STATUS sfmc_TB_STATUS) {
		
		String where = "";
		
		try{
			if(!"".equals(sfmc_TB_STATUS.getSearchCustName())){
				where += "AND B.CustName LIKE '%"+sfmc_TB_STATUS.getSearchCustName()+"%'\n";
			}
			if(!"".equals(sfmc_TB_STATUS.getSearchCustPhone())){
				where += "AND B.CustPhone LIKE '%"+sfmc_TB_STATUS.getSearchCustPhone()+"%'\n";
			}

			sfmc_TB_STATUS.setWhere(where);
			return sfmcCountStatusDao.getMonthlyStatusList(sfmc_TB_STATUS);
		}
		catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	
	@Override
	public List<Sfmc_TB_STATUS> getYearlyStatusList(Sfmc_TB_STATUS sfmc_TB_STATUS) {
		return sfmcCountStatusDao.getYearlyStatusList(sfmc_TB_STATUS);
	}
}
